home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: deallocTempFilesPages.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:02 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "latch.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "bf_macro.h"
- #include "volume.h"
- #include "openlog.h"
- #include "trans.h"
- #include "page.h"
- #include "bitmap.h"
- #include "file.h"
- #include "consist.h"
- #include "deallocinfo.h"
- #include "bf_extfuncs.h"
- #include "fi_extfuncs.h"
- #include "io_extfuncs.h"
- #include "trans_intfuncs.h"
- #include "bf_globals.h"
- #include "io_globals.h"
-
-
- /*
- * This function deallocates the temporary files and pages allocated
- * by a transaction.
- */
-
- void
- deallocTempFilesPages (
-
- TRANSREC *transRec
- )
- {
-
- PAGEDEALLOCINFO *currPage;
- FILEDEALLOCINFO *currFile;
- PAGE2SIZE page2size, prevPage2size;
- #define PID_LIST_LEN 10
- PID pidList[PID_LIST_LEN];
- VOLREC *volRec;
- int i;
-
-
- TRACE(TR_TRANS, TR_LEVEL_1);
-
- /*
- * Destroy each temporary file
- */
- while ((currFile = (FILEDEALLOCINFO*) listDeq(&(transRec->tempFileList))) != NULL) {
-
- volRec = io_FindVolRec(currFile->fid.pid.volid);
- if (volRec == NULL) {
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- if (io_MarkPage(volRec, &(currFile->fid.pid), PAGE_FILEHDR, FALSE) != esmNOERROR) {
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- if (fi_DestroyFile(UserBufGroup, &(currFile->fid.pid), NULL, TRUE, FALSE) != esmNOERROR) {
- SM_ERROR(TYPE_CRASH, esmINTERNAL);
- }
- poolEnq(&FileDeallocInfoPool, &(currFile->list));
- }
-
-
- /*
- * Deallocate pages in chunks of PID_LIST_LEN
- */
- i = 0;
- while ((currPage = (PAGEDEALLOCINFO*) listDeq(&(transRec->tempPageList))) != NULL) {
-
- CHECK_PAGEDEALLOCINFO_MAGIC(currPage);
- page2size = currPage->page2size;
-
- /*
- * if the page list is full, or we came across is different
- * type of page and we are not at the first page of the
- * pidList, deallocate what we have to far.
- */
- if (i == PID_LIST_LEN || (prevPage2size != page2size && i != 0)) {
- if (io_DeallocPages(prevPage2size, i, pidList, NULL, FALSE, TRUE) != esmNOERROR) {
- SM_ERROR(TYPE_CRASH, esmINTERNAL);
- }
-
- i = 0;
- }
-
- if (i == 0) {
- prevPage2size = page2size;
- }
- pidList[i] = currPage->pid;
-
- /*
- * Remove the page from the buffer and
- * Return the page info to the Pool
- */
- bf_InvalidatePage(&(currPage->pid));
- poolEnq(&PageDeallocInfoPool, &(currPage->list));
-
- i++;
- }
-
- /* finish deallocating */
- if (i > 0) {
- if (io_DeallocPages(prevPage2size, i, pidList, NULL, FALSE, TRUE) != esmNOERROR) {
- SM_ERROR(TYPE_CRASH, esmINTERNAL);
- }
- }
- }
-
-